Release 10.1A: OpenEdge Development:
Progress 4GL Reference


– Unary negative operator

Reverses the sign of a numeric expression. Do not confuse this operator with the subtraction operator that subtracts one expression from another.

Syntax

- expression 

expression

An expression whose value is numeric.

Example

If you supply a negative value for the variable x, the following example procedure uses the unary negative operator (-) to reverse the sign of x, producing the absolute value of x (abs-x):

r-uneg.p
DEFINE VARIABLE x AS DECIMAL LABEL "X".
DEFINE VARIABLE abs-x AS DECIMAL LABEL "ABS(X)".

REPEAT:
  SET x.
  IF x < 0
  THEN abs-x = -x
  ELSE abs-x = x.
  DISPLAY abs-x.
END. 


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095